home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Other Stuff / Other Stuff ’97 / PowerOS Development / basic kernel source / entry.S < prev    next >
Encoding:
Text File  |  1997-09-24  |  3.4 KB  |  127 lines  |  [TEXT/R*ch]

  1. /*
  2.     entry.S
  3.     the entry point for PowerOS
  4.     copyright 1996-1997 by Ben Martz
  5.     all rights reserved world wide
  6.  
  7.     ANY AND ALL MODIFICATIONS TO THIS SOURCE MUST CREDIT THE ORIGINAL
  8.     AUTHOR, BEN MARTZ (benmartz@ic.net), AND MUST BE GIVEN TO THE AUTHOR
  9.     FOR INTEGRATION INTO THE MAIN PowerOS SOURCE TREE. THANK YOU FOR YOUR
  10.     COOPERATION!
  11. */
  12.  
  13. #include "stdhdr.s"
  14. #include "exception_stub.s"
  15.  
  16. /******************************************************************************/
  17.  
  18.     .text
  19.     .globl    _start
  20. _start:
  21.     /* adjust the MSR, just to make sure it's okay */
  22.     lis    r31,MSR_KERNEL@h
  23.     ori    r31,r31,MSR_KERNEL@l
  24.     mtmsr    r31
  25.     sync
  26.     
  27.     /* jump over the exception handlers to the real _start */
  28.     lis    r31,_start2@ha
  29.     ori    r31,r31,_start2@l
  30.     mtlr    r31
  31.     blr
  32.     
  33. /******************************************************************************/
  34.  
  35.     exception(0x00100,_SystemReset)
  36.     exception(0x00200,_MachineCheck)
  37.     exception(0x00300,_DataStorage)
  38.     exception(0x00400,_InstructionStorage)
  39.     exception(0x00500,_External)
  40.     exception(0x00600,_Alignment)
  41.     exception(0x00700,_Program)
  42.     exception(0x00800,_FPUnavailable)
  43.     exception(0x00900,_Decrementer)
  44.     exception(0x00a00,_IOException)
  45.     exception(0x00b00,_UnknownException)
  46.     exception(0x00c00,_SystemCall)
  47.     exception(0x00d00,_Trace)
  48.     exception(0x00e00,_FPAssist)
  49.     exception(0x00f00,_UnknownException)
  50.     exception(0x01000,_UnknownException)
  51.     exception(0x01100,_UnknownException)
  52.     exception(0x01200,_UnknownException)
  53.     exception(0x01300,_UnknownException)
  54.     exception(0x01400,_UnknownException)
  55.     exception(0x01500,_UnknownException)
  56.     exception(0x01600,_UnknownException)
  57.     exception(0x01700,_UnknownException)
  58.     exception(0x01800,_UnknownException)
  59.     exception(0x01900,_UnknownException)
  60.     exception(0x01a00,_UnknownException)
  61.     exception(0x01b00,_UnknownException)
  62.     exception(0x01c00,_UnknownException)
  63.     exception(0x01d00,_UnknownException)
  64.     exception(0x01e00,_UnknownException)
  65.     exception(0x01f00,_UnknownException)
  66.     exception(0x02000,_UnknownException)
  67.     exception(0x02100,_UnknownException)
  68.     exception(0x02200,_UnknownException)
  69.     exception(0x02300,_UnknownException)
  70.     exception(0x02400,_UnknownException)
  71.     exception(0x02500,_UnknownException)
  72.     exception(0x02600,_UnknownException)
  73.     exception(0x02700,_UnknownException)
  74.     exception(0x02800,_UnknownException)
  75.     exception(0x02900,_UnknownException)
  76.     exception(0x02a00,_UnknownException)
  77.     exception(0x02b00,_UnknownException)
  78.     exception(0x02c00,_UnknownException)
  79.     exception(0x02d00,_UnknownException)
  80.     exception(0x02e00,_UnknownException)
  81.     exception(0x02f00,_UnknownException)
  82.  
  83. /******************************************************************************/
  84.  
  85.     . = 0x03000
  86.     .globl    _start2
  87. _start2:
  88.     /* move to the kernel stack */
  89.     lis    r31,kernel_stack@ha
  90.     ori    r31,r31,kernel_stack@l
  91.     mr    r1,r31
  92.     
  93.     /* let's do the rest in C */
  94.     /* put the ppc chip type into r4 */
  95.     /* kvars are already in r3 */
  96.     mfspr    r4,PVR
  97.     rlwinm    r4,r4,16,16,31
  98.     lis    r31,kernel_main@ha
  99.     ori    r31,r31,kernel_main@l
  100.     lis    r30,MSR_KERNEL@h
  101.     ori    r30,r30,MSR_KERNEL@l
  102.     mtsrr0    r31
  103.     mtsrr1    r30
  104.     rfi
  105.     
  106. /******************************************************************************/
  107.  
  108.     /* this is a failsafe - we should never reach here! */
  109. _forever:
  110.     nop
  111.     b    _forever
  112.  
  113. /******************************************************************************/
  114.  
  115.     .data
  116.  
  117.     .align    4
  118.     .space    8192    /* 8K is reasonable for a OS stack */
  119.     .globl    kernel_stack
  120. kernel_stack:
  121.     nop        /* remember, a stack pointer points at the top! */
  122.  
  123.     .align    4
  124.     .globl    exception_frame
  125. exception_frame:
  126.     .space    1024    /* more than enough for all the registers */
  127.